package com.idcf.boathouse.account.controller;

import com.idcf.boathouse.account.entity.OrderInvoice;
import com.idcf.boathouse.account.param.OrderInvoiceCreateParam;
import com.idcf.boathouse.account.service.OrderInvoiceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.ReportAsSingleViolation;
import javax.validation.Valid;

/**
 * 订单发票表(OrderInvoice)表控制层
 *
 * @author isaiah.wang
 * @since 2021-06-27 10:50:49
 */
@Api(value = "")
@RestController
@RequestMapping("/orderInvoice")
public class OrderInvoiceController {
    /**
     * 服务对象
     */
    @Autowired
    private OrderInvoiceService orderInvoiceService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping(value = "/get/{id}")
    public OrderInvoice getById(@ApiParam(value = "id", name = "唯一标识") @PathVariable(value = "id") Integer id) {
        OrderInvoice orderInvoice = orderInvoiceService.getById(id);
        return orderInvoice;
    }

    /**
     * 创建电子票据
     *
     * @param orderInvoice
     * @return java.lang.String
     * @author Isaiah.Wang
     * @date 2021/6/27 上午11:32
     */
    @PostMapping("/createInvoice")
    public String createOrderInvoice(@RequestBody @Validated OrderInvoiceCreateParam orderInvoice) {
        String message = orderInvoiceService.createOrderInvoice(orderInvoice);
        return message;
    }


}
